#ifndef __MYIIC_H
#define __MYIIC_H
#include "sys.h"

//IO????
//stm32f103??GPIO?CRL?CRH??????GPIO???????,CRL???0~7??,CRH???8~15???
#define SDA_IN()  {GPIOB->CRL&=0X0FFFFFFF;GPIOB->CRL|=(u32)8<<28;}
#define SDA_OUT() {GPIOB->CRL&=0X0FFFFFFF;GPIOB->CRL|=(u32)3<<28;}
#define u8 uint8_t
//IO????	 
#define IIC_SCL    PBout(6) //SCL
#define IIC_SDA    PBout(7) //SDA	 
#define READ_SDA   PBin(7)  //??SDA 

//IIC??????
void IIC_Init(void);                //???IIC?IO?				 
void IIC_Start(void);				//??IIC????
void IIC_Stop(void);	  			//??IIC????
void IIC_Send_Byte(u8 txd);			//IIC??????
u8 IIC_Read_Byte(unsigned char ack);//IIC??????
u8 IIC_Wait_Ack(void); 				//IIC??ACK??
void IIC_Ack(void);					//IIC??ACK??
void IIC_NAck(void);				//IIC???ACK??

void IIC_Write_One_Byte(u8 daddr,u8 addr,u8 data);
u8 IIC_Read_One_Byte(u8 daddr,u8 addr);	  
#endif
